//-----------------------------------------------------------------------
// <copyright file="ProvinceService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class ProvinceService
    {
        #region Province

        public static void CreateProvince(Province province)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                provinceDAO.CreateProvince(province);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateProvinceException, ex);
            }
        }        

        public static void UpdateProvince(Province province)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                provinceDAO.UpdateProvince(province);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateProvinceException, ex);
            }
        }        

        public static void DeleteProvince(long provinceId)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                provinceDAO.DeleteProvince(provinceId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteProvinceException, ex);
            }
        }
        
        public static Province GetProvince(long provinceId)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                return provinceDAO.GetProvince(provinceId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProvinceException, ex);
            }
        }                

        public static ProvinceCollection GetProvinceList(ProvinceColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                return provinceDAO.GetProvinceList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProvinceListException, ex);
            }
        }        

        public static ProvinceCollection GetProvinceList(ProvinceColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                return provinceDAO.GetProvinceList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProvinceListException, ex);
            }
        }        

	    public static ProvinceCollection GetProvinceListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                return provinceDAO.GetProvinceListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProvinceListException, ex);
            }
        }        

        public static ProvinceCollection GetProvinceListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                ProvinceDAO provinceDAO = new ProvinceDAO();
                return provinceDAO.GetProvinceListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetProvinceListException, ex);
            }
        }        

        #endregion
    }
}